#include "../begonia.h"
#include "../bullet/monitoredbullet.h"
#include "../bullet/prebullet.h"
#include "boss_2_4.h"
#include "../base/scene.h"

double towery[7]={30,85,120,155,190,225,280};
double towerr[7]={30,15,15,15,15,15,30};
double towerc_r[7]={1.0,1.0,1.0,0.0,0.0,0.0,0.5};
double towerc_g[7]={0.0,0.5,1.0,1.0,0.5,0.0,0.0};
double towerc_b[7]={0.0,0.0,0.0,0.0,1.0,1.0,1.0};
boss_2_4::boss_2_4():boss(192.0,350.0,20.0,0.0,0.0,&f.head)
{
    int i;
    for(i=0;i<7;i++) tower[i]=false;
}
boss_2_4::boss_2_4(double tx,double ty,double tr,double tvx,double tvy,bullet *h):boss(tx,ty,tr,tvx,tvy,h)
{
}
void boss_2_4::clone(bullet *h)
{
    new boss_2_4(x,y,r,vx,vy,h);
}
bool boss_2_4::move()
{
    int i;
    for(i=0;i<7;i++)
    { 
        if(!tower[i]&&((int)t+295-i*5)/300>((int)tlast+295-i*5)/300)
        {
            prebullet *t=new prebullet(30,&pre[i],&f.head);
            bullet *t2=new monitoredbullet(192.0,towery[i],towerr[i],0.0,0.0,&tower[i],&t->h2);
            t2->c_r=1.0;t2->c_b=1.0;
        }
    }
    if((int)t/20>(int)tlast/20)
    {
        double t0=atan2(f.py-y,f.px-x);
        for(i=0;i<20;i++)
        {
            new bullet(x,y,10,cos(2.0*M_PI*i/20+t0)*2.0,sin(2.0*M_PI*i/20+t0)*2.0,&f.head);
        }
        for(i=0;i<7;i++)
        {
            if(tower[i]&&!pre[i])
            {
                t0=t*0.01/(7-i);
                bullet *t=new bullet(192,towery[i],6,cos(t0)*towerr[i]*0.1*(i%2*2-1),sin(t0)*towerr[i]*0.0333,(int)(t0/M_PI)%2?&f.head:this);
                t->c_r=towerc_r[i];
                t->c_g=towerc_g[i];
                t->c_b=towerc_b[i];
            }
        }
    }
    return true;
}
